package com.itheima.mapper;

import com.itheima.pojo.Account;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Author zhouxiangyang
 * @Date 2022/4/6 20:54
 */

public interface AccountMapper {

    /**
     * 根据id查询账户信息
     * @param id 账户id
     * @return
     */
    @Select("select * from tb_account where id=#{id}")
    Account findById(int id);

    /**
     * 根据id修改账户金额
     * @param id 账户id
     * @param amount 要加的金额
     */
    @Update("update tb_account set amount=amount + #{amount} where id=#{id}")
    void updateAmount1(@Param("id") int id,@Param("amount") double amount);
    /**
     * 根据id修改账户金额
     * @param id 账户id
     * @param amount 要加的金额
     */
    @Update("update tb_account set amount=amount - #{amount} where id=#{id}")
    void updateAmount2(@Param("id") int id,@Param("amount") double amount);
}
